package com.one.common.config;


import android.content.Context;

import com.one.common.utils.Logger;
import com.one.common.utils.SPUtils;
import com.one.common.utils.StringUtils;

import cn.jpush.android.api.JPushInterface;

/**
 * Author：zhulunjun
 * Time：2017/9/16
 * description： 本地持久化
 */

public class CPersisData {

    public static final String MOBILE = "mobile";
    public static final String IS_LOGIN = "is_login";
    public static final String USER_INFO = "user_info";
    public static final String JPUSH_ID = "jpush_id";

    public static boolean getIsLogin() {
        return SPUtils.getBoolean(IS_LOGIN, false);
    }

    public static void setIsLogin(boolean isLogin) {
        SPUtils.putBoolean(IS_LOGIN, isLogin);
    }

    public static String getUserInfo() {
        return SPUtils.getString(USER_INFO,"");
    }

    public static void setUserInfo(String userInfo) {
        SPUtils.putString(USER_INFO, userInfo);
    }

    public static String getJpushId() {
        return SPUtils.getString(JPUSH_ID,"");
    }

    public static void setJpushId(Context context) {
        String resId = JPushInterface.getRegistrationID(context);
        Logger.e("-------------------- resID "+resId);
        if(StringUtils.isNotBlank(resId)){
            SPUtils.putString(JPUSH_ID, resId);
        }

    }
}
